<template>
  <button class="launch-btn">
    <div class="bg-after relative w-full h-full p-[7px 10.5px] py-[7px] px-[10.5px]">
      <div v-for="x in 4" :key="x" class="triangle absolute block z-1 w-[10px] h-[10px] border-2px"
        :style="{ '--x-r': `${90 * (x - 1)}deg` }"
        :class="{ 'top-0': x < 3, 'right-0': [2, 3].includes(x), 'left-0': [1, 4].includes(x), 'bottom-0': x > 2 }">
        <span class="line block z-1 w-[5px] h-[5px] border-1px mt-2px ml-2px"></span>
      </div>
      <div class="content w-full h-full relative z-0 text-white text-[16px] tracking-[4px] flc">
        <div class="content-border absolute -top-7px w-19/20 left-1/2 transform -translate-x-1/2 left-0 h-1px z-1">
        </div>
        <div class="content-border absolute -bottom-8px w-101/100 -left-1/100 h-1px z-1 opacity-75">
        </div>
        <div class="content-bg absolute w-full h-full top-0 left-0 z-0"></div>
        <div class="content-text relative z-1 font-bold">
          <slot />
        </div>
      </div>
    </div>
  </button>
</template>

<script
  lang="ts"
  setup
  name="PureBtn"
>

defineProps({
  loading: {
    type: Boolean,
    default: false
  }
})
</script>

<style scoped lang="scss">
@keyframes content {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

@keyframes content-bg {
  0% {
    opacity: 0;
  }

  50% {
    opacity: 0.8;
  }

  80% {
    opacity: 0.6;
  }

  100% {
    opacity: 1;
  }
}

@keyframes content-text {
  0% {
    @include set-clip(inset(100%));
  }

  100% {
    @include set-clip(inset(-10%));
  }
}

.launch-btn {
  position: absolute;
  bottom: 35px;
  left: 50%;
  width: 370px;
  height: 70px;
  margin-left: -185px;

  &:hover {
    width: 380px;
    margin-left: -190px;
  }

  .bg-after {
    transition: all 0.15s;

    $t: 0.4s;

    .triangle {
      @include triangle(50%, 50%);
      transform: rotate(var(--x-r));
      animation-duration: $t;
      animation-timing-function: linear;
      animation-delay: calc($t / 2);
      animation-fill-mode: both;
      animation-iteration-count: 1;
      border-style: solid;
      border-color: #ffffff;
      border-right: none;
      border-bottom: none;

      .line {
        border-style: solid;
        border-color: #ffffff;
        border-right: none;
        border-bottom: none;
      }

      &:nth-child(1) {
        animation-name: triangle-top-left;
      }

      &:nth-child(2) {
        animation-name: triangle-top-right;
      }

      &:nth-child(3) {
        animation-name: triangle-bottom-right;
      }

      &:nth-child(4) {
        animation-name: triangle-bottom-left;
      }
    }

    .content {
      width: 352px;
      height: 55px;
      position: absolute;
      left: 50%;
      margin-left: -174.5px;
      font-size: 24px;

      &:hover {
        background: rgba(255, 255, 255, 0.35);
        box-shadow: inset 0px 0px 6px 0px rgba(255, 255, 255, 0.5);
      }

      .content-bg {
        @apply backdrop-blur-3px backdrop-filter;
        background: rgba(255, 255, 255, 0.2);
        box-shadow: inset 0px 0px 6px 0px rgba(255, 255, 255, 0.5);
        animation: content $t linear calc($t / 2) both;
      }

      .content-border {
        animation: content-bg $t * 0.6 linear calc($t * 1.5) 1 both;
        background: #ffffff;
      }

      .content-text {
        animation: content-text calc($t * 0.6) linear $t 1 both;
      }
    }
  }
}
</style>
